package com.example.adms.message.controller;


import com.example.adms.message.service.MessageService;
import com.example.adms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hyt
 * @since 2023-04-24
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    MessageService messageService;

    @GetMapping("/hasEvent")
    public Result hasEvent(String userId){
        Map<String,Integer> map = messageService.hasEvent(userId);
        return Result.success(map);
    }

    @GetMapping("/clearUnreadMsg")
    public Result clearUnreadMsg(String userId){
        boolean result = messageService.clearUnreadMsg(userId);
        if (result){
            return Result.success(null);
        }
        else {
            return Result.fail(501,"清除未读失败");
        }
    }

}
